﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using HA.ModFlow.Domain.DomainLayer;

using System.Windows.Controls;

using HA.ModFlow.Controls;


namespace HA.ModFlow.Application
{
    public class BCFMFViewModel : MDTVIViewModel
    {

        public BCFMFViewModel(MDTVIViewModel parent, BCFData inner)
          : base(parent, false)
      {

          this._contextMenu = new System.Windows.Controls.ContextMenu();

          MenuItem mi = new MenuItem();

          mi.Command = AppCommands.BcfEdit;

          this._imageSource = VMImageSource.globaloption;


          this._isShowCheck = false;


          this._bcfData = inner;


          this.LoadChildren();

      }



        BCFData _bcfData;


        public override System.Windows.Input.ICommand DoubleClickCommand
        {
            get
            {
                return AppCommands.BcfEdit;
            }
        }



      public override string Desc
      {
          get
          {
              return "流动包BCF";
          }


      }


      protected override void LoadChildren()
      {
          //base.LoadChildren();


          //TransmissivityFlowVM tran = new TransmissivityFlowVM(this,this._bcfData);

          //this.Children.Add(tran);


          //HKFlowVM hk = new HKFlowVM(this,this._bcfData.Parent);

          //this.Children.Add(hk);

          //if (ProjectSerivce.DefaultService.Project.MfData.FlowData.GridData.LayersCount > 1)
          //{
          //    LeakanceFlowVM leak = new LeakanceFlowVM(this, this._bcfData);

          //    this.Children.Add(leak);
          //}

          //if (ProjectSerivce.DefaultService.Project.MfData.FlowData.IsHaveTransient)
          //{
          //    PrimaryStorageFlowVM pri = new PrimaryStorageFlowVM(this, this._bcfData);

          //    this.Children.Add(pri);


          //    SecondaryStorageFlowVM sec = new SecondaryStorageFlowVM(this, this._bcfData);

          //    this.Children.Add(sec);
          //}

          //if (ProjectSerivce.DefaultService.Project.MfData.FlowData.CanWet)
          //{
          //    WetDryFlowVM wetdry = new WetDryFlowVM(this, this._bcfData.Parent);

          //    this.Children.Add(wetdry);
          //}
          this.ReLoadChildren();

          ProjectService.DefaultService.Project.MfData.FlowData.BcfData.BCFDataChanged+=new EventHandler(BcfData_BCFDataChanged);

      }
      void BcfData_BCFDataChanged(object sender, EventArgs e)
      {
          this.ReLoadChildren();

      }

      void ReLoadChildren()
      {
          this.Children.Clear();

          base.LoadChildren();


          TransmissivityFlowVM tran = new TransmissivityFlowVM(this, this._bcfData);

          this.Children.Add(tran);


          HKFlowVM hk = new HKFlowVM(this, this._bcfData.Parent);

          this.Children.Add(hk);

          if (ProjectService.DefaultService.Project.MfData.FlowData.GridData.LayersCount > 1)
          {
              LeakanceFlowVM leak = new LeakanceFlowVM(this, this._bcfData);

              this.Children.Add(leak);
          }

          if (ProjectService.DefaultService.Project.MfData.FlowData.IsHaveTransient)
          {
              PrimaryStorageFlowVM pri = new PrimaryStorageFlowVM(this, this._bcfData);

              this.Children.Add(pri);


              SecondaryStorageFlowVM sec = new SecondaryStorageFlowVM(this, this._bcfData);

              this.Children.Add(sec);
          }

          if (ProjectService.DefaultService.Project.MfData.FlowData.CanWet)
          {
              WetDryFlowVM wetdry = new WetDryFlowVM(this, this._bcfData.Parent);

              this.Children.Add(wetdry);
          }
      }


      protected override void OnSelectedChanged()
      {
          if (this.IsSelected)
          {

              UIModule.DefaultModule.RibbonV2ViewModel.ViewOpViewModel.ToolVM.CurrentTool = APPTOOLMODE.GRID3D;

          }
      }

    }
}
